Skip to main content

Tab: <device name> I/O Mapping

Devices with I/O channels

This tab is displayed in device editors for devices with I/O channels. It shows the available channels and allows for the mapping of input, output, and memory addresses of the controller to variables or entire function blocks of the application. You create the 'I/O Mapping' in this way.

For more information, see: Configuring Devices and I/O Mapping

The application that is to take care of the I/O handling is defined on the PLC Settings tab.

Tip

You can use the "Online Configuration Mode" if the device supports it. In this mode, you can access the I/Os of the hardware without having to download an actual application to the device beforehand.

Tip

If an I/O channel is not referenced in the application, then its value will not be updated. If you want to monitor non-referenced I/O channels, then you need to enable the Always update variables option on the Tab: PLC Settings. Alternatively, you could also enable this option on the I/O Mapping tab of a device. Then enabling is valid only for this one device and its children.

Mapping data types which are "too large"

If a variable of a data type that is larger than a byte is mapped to a byte address, the value of the variable will be truncated to byte size there. For monitoring the variable value in the I/O Mapping dialog, this means that, in the root element of the address, the value is displayed which the variable currently has in the project. The current individual bit values of the byte are displayed in succession in the bit elements below that, but this may not be sufficient for the entire variable value.

Example of the <device name> I/O Mapping tab for a CAN bus slave:

_cds_img_io_mapping_dialog.png

The tab contains a table for editing the I/O mapping. The information displayed for the inputs and outputs originates from the device description.

Find (1)

Input field for a string to search for in the mapping table

The search results are highlighted in yellow.

Filter (2)

List box with filters for the I/O mappings displayed in the mapping table:

  • Show all

  • Show only outputs

  • Show only inputs

  • Show only unmapped variables

  • Show only mapped variables

  • Show only mapping to existing variables

  • Show only mapping to new variables

_cds_icon_add_fb.pngAdd FB for IO channel (11)

Depending on the device, available if the channel entry is selected in the mapping table

Opens the Select Function Block dialog for selecting the function block that should be linked directly to the channel

_cds_icon_goto_definition.pngGo to instance (12)

Available if the entry is selected in the mapping table

Jumps to the corresponding entry on the <device name> IEC Objects tab

Variable

Depending on the device, the inputs and outputs of the device are displayed as nodes and below them, indented, the associated channels or, depending on the device, only the implicitly created device instance.

The symbol indicates the type of channel:

_cds_icon_input_channel.png: Input

_cds_icon_output_channel.png: Output

Double-click the cell to open an input field.

  • Possibility 1: The variable already exists.

    Specify the full path: <application name>.<POU name>.<variable name>

    Example: app1.plc_prg.ivar; Input Assistant via _cds_icon_three_dots.png

  • Possibility 2: The variable does not exist yet.

    Specify simple names

    Automatically created internally as a global variable

Depending on the device, inputs or outputs can be linked directly to a function block. In this case, the _cds_icon_add_fb.pngAdd FB for IO channel button can be clicked. See above.

Mapping (3)

Type of mapping:

  • _cds_icon_map_to_existing_variable.png: Existing variable

  • _cds_icon_create_new_variable.png: New variable

  • _cds_icon_map_fb.png: Mapping to function block instance

Channel (4)

Symbolic name of the channel.

Address (5)

Address of the channel (example: %IW0)

Address strikethrough: Indicates that you should not assign any more variables to this address. Reason: Although the variable specified here is managed – as an existing variable –at a different memory location, ambiguity could result when the values are written, particularly with outputs.

_cds_icon_address_fixed.png: Indicates that this address has been edited and fixed

If the arrangement of the device objects in the device tree changes, then CODESYS does not adapt this address automatically.

Type (6)

Data type of the channel (example: BOOL)

Structures or bit fields defined in the device description are displayed only if they are part of the IEC standard and are identified as IEC data types in the device description. Otherwise the table cell remains empty.

When mapping structured variables, the editor prevents you from specifying both the structure variable (example: %QB0) and individual structure elements (example: %QB0.1 and QB0.2). Therefore, if there is a main entry with a subtree of bit channel entries in the mapping table, then the following applies: You can input a variable either into the line of the main entry, or into the lines of the subelements (bit channels), but not into both.

Default Value

Default value of the parameter that applies to the channel: Appears only if the option Set all outputs to default is selected in the PLC Settings for the behavior of the outputs at stop.

Note: For compiler version V3.5 SP11 and higher, the initialization value of the variables is used automatically as the default value when mapping to an existing variable. You can edit the Default value field only if you map to a new created variable. In older versions, users had to specify explicitly that the default value and initialization value were identical.

Unit (7)

Unit for the parameter value (example: ms for milliseconds)

Description (8)

Short description of the parameter

Current value

Actual value of the parameter applied to the channel; displayed in online mode only

Tip

The change of the default value by an online change is allowed, however the value is applied only after a "Reset cold" or "Reset warm".

Reset Mapping (9)

CODESYS resets the mapping settings to the default values as defined in the device description file.

Always update variables (10)

Definition for the device object about updating I/O variables

The default value is defined in the device description:

  • Use parent device setting: Update according to the setting of the superordinate device.

  • Enabled 1 (use bus cycle task if not used in any task): CODESYS updates the I/O variables in the bus cycle task if they are not used in any other task.

  • Enabled 2 (always in bus cycle task): CODESYS updates all variables in each cycle of the bus cycle task, regardless of whether they are used and whether they are mapped to an input or output channel.

Tip

If a UNION is represented by I/O channels in the mapping dialog, it depends on the device whether mapping to the root element is also possible.

For more information, see: Fieldbus Devices and I/O Drivers

Devices with I/O drivers

For devices with I/O drivers, you can set the bus cycle task here in the I/O Mapping tab if the general settings should not be used (PLC Settings tab).

Table 50. Bus cycle options

Bus Cycle Task

The list box provides all tasks which are defined in the task configuration of the active application (example: MainTask. In case of Use parent bus cycle setting, the settings of the parent node will be used.



General information about the bus cycle task

Generally, for each IEC task, the used input data is read at the start of each task (1) and the written output data is transferred to the I/O driver at the end of the task (3). The implementation in the I/O driver is decisive for additional transfer of the I/O data. It is responsible for the time frame and time point that the actual transfer to the corresponding bus system occurs.

The bus cycle task of the PLC can be defined globally for all fieldbuses in the PLC settings. For some fieldbuses, however, you can change this independent of the global setting. The task with the shortest cycle time is used as the bus cycle task (setting: unspecified in the PLC settings). The messages are normally sent on the bus in this task.

Other tasks copy only the I/O data from an internal buffer that is exchanged only with the physical hardware in the bus cycle task.

_task_diagram_standard.png
(1) Read inputs from input buffer             (2) IEC task
(3) Write outputs to output buffer            (4) Bus cycle
(5) Input buffer                              (6) Output buffer
(7) Copy data to/from bus
(9) Bus cycle task, priority 1, 1 ms
(10) Bus cycle task, priority 5
(11) Bus cycle task, priority 10, interrupted by task 5

Task usage

The Task Deployment tab provides an overview of used I/O channels, the set bus cycle task, and the usage of channels.

Warning

If an output is written in various tasks, then the status is undefined, as this can be overwritten in each case.

If the same inputs are used in various tasks, then it is possible for the input to change during the processing of a task. This happens when the task is interrupted by a task with a higher priority and causes the process image to be read again. Solution: At the beginning of the IEC task, copy the input variables to variables and then work only with the local variables in the rest of the code.

Conclusion: Using the same inputs and outputs in several tasks does not make any sense and can lead to unexpected reactions in some cases.